package com.refactor.practice.movie;

/**
 * @Desc: 电影类型创建工厂
 * @Author: zoupinluowei@qianxin.com
 * @Date: 2024/9/6 22:10
 * @Since: 2.2.0
 */
public class MovieTypeFactory {

    public static final int REGULAR = 0;
    public static final int NEW_RELEASE = 1;
    public static final int CHILDREN = 2;


    private MovieTypeFactory() {
    }

    /**
     * 创建电影类型
     *
     * @param code
     * @return
     */
    public static AbstractMovieType createMovieType(int code) {
        switch (code) {
            case REGULAR:
                return new RegularMovieType();
            case NEW_RELEASE:
                return new NewReleaseMovieType();
            case CHILDREN:
                return new ChildrenMovieType();
            default:
                throw new RuntimeException("找不到指定的类型：" + code);
        }
    }


}
